import instance from "@/utils/request";

enum API{
  ACL_USER_URL='/admin/acl/user',
  ADD_USER_URL='/admin/acl/user/save',
  UPDATE_USER_URL='/admin/acl/user/update',
  ALLROLE_URL='/admin/acl/user/toAssign',
  SETROLE_URL='/admin/acl/user/doAssignRole',
  DELETE_USER_URL='/admin/acl/user/remove',
  ALL_DELETE_USER_URL='/admin/acl/user/batchRemove'
}

// 用户列表
export const UserListAPI=(page:number,limit:number,username:any)=>{
  return instance.get(API.ACL_USER_URL+`/${page}/${limit}/?username=${username}`)
}

// 添加
export const AddUserAPI=(data:any)=>{
  return instance.post(API.ADD_USER_URL,data)
}

// 更新
export const updateUserAPI=(data:any)=>{
  return instance.post(API.UPDATE_USER_URL,data)
}

// 获取职位
export const AllUserRoleAPI=(UserId:any)=>{
  return instance.get(API.ALLROLE_URL+`/${UserId}`)
}

// 分配职位
export const SetRoleAPI=(data:any)=>{
  return instance.post(API.SETROLE_URL,data)
}

// 删除用户
export const DeleteUserAPI=(userId:number)=>{
  return instance.post(API.DELETE_USER_URL+`/${userId}`)
}
// 批量删除用户
export const AllDeleteUserAPI=(idList:number[])=>{
  return instance.post(API.ALL_DELETE_USER_URL,{data:idList})
}
